/*
 * MessageProducer.h
 *
 *  Created on: Jul 19, 2013
 *      Author: m
 */

#ifndef MESSAGEPRODUCER_H_
#define MESSAGEPRODUCER_H_

#include "MessageQueue.h"
#include "FixedLengthMessage.h"

namespace communication
{

template <class T> class MessageProducer
{
protected:
    MessageQueue<FixedLengthMessage> m_channel;

public:
    MessageProducer( std::string channelName ) :
        m_channel( channelName )
    {
    }

    virtual ~MessageProducer()
    {
    }

    void produce( std::string destination, messageType_t type, const T &data )
    {
        FixedLengthMessage msg( sizeof(T), (char*) &data, destination );

        m_channel.put( type, msg );
    }
};

} /* namespace communication */
#endif /* MESSAGEPRODUCER_H_ */
